#include <bits/stdc++.h>
using namespace std;
struct Order {
  int ts, id;
};
Order order[100001];
bool cmp(Order x, Order y) { return x.ts < y.ts; }
struct Store {
  // int id;
  int level;
  bool inCashe;
  vector<int> orderTime;
};
Store store[100001];

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  for (int i = 1; i <= M; i++) {
    cin >> order[i].ts >> order[i].id;
  }
  sort(order + 1, order + M + 1, cmp);

  for (int i = 1; i <= M; i++) {
    int id = order[i].id;
    int ts = order[i].ts;
    store[id].orderTime.push_back(ts);
  }

  for (int i = 1; i <= N; i++) {
    int now = 0;
    Store &s = store[i];
    for (auto current : s.orderTime) {
      int elapsed = current - now - 1;
      s.level -= elapsed * 1;
      if (s.level < 0)
        s.level = 0;

      now = current;
      s.level += 2;

      if (s.level <= 3) {
        s.inCashe = false;
      } else if (s.level > 5) {
        s.inCashe = true;
      }
    }

    int r = s.orderTime.size();
    if (r > 0) {
      int elapsed = T - s.orderTime[r - 1];
      s.level -= elapsed * 1;
    }
    if (s.level <= 3) {
      s.inCashe = false;
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (store[i].inCashe)
      ans++;
  }
  cout << ans;
  return 0;
}